package com.gzkemays.music.controller;

import com.gzkemays.music.service.MusicService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.annotation.Resource;

@Controller
public class IndexController {
  @Resource MusicService musicService;

  @GetMapping("index")
  public String indexPage() {
    return "index";
  }

  @GetMapping("music/{id}")
  public String musicPage(@PathVariable("id") int id, Model model) {
    model.addAttribute("music", musicService.findUrlById(id));
    return "music";
  }
}
